<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>管理系统</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  {:widget_st('layui','css')}
  {:widget_st('admin','css')}
</head>
{:do_action('admin_head')}
<body>

  <div class="layui-fluid">
    <div class="layui-card">
      <div class="layui-card-body">
        
        <table class="layui-table">
            <colgroup>
              <col width="30">
              <col>
            </colgroup>
            <thead>
              <tr>
                <th>ID</th>
                <th>类型</th>
                <th>备份路径</th>
                <th>创建时间</th>
                <th>大小</th>
                <th>操作</th>
              </tr> 
            </thead>
            <tbody>
              <?php foreach($list as $k => $vo){ ?>
                <tr>
                  <td><?php echo $k+1;?></td>
                  <td>
                    <?php if($vo['ori']=='模板目录'){ ?>

                      <span class="layui-badge layui-bg-blue">{:ZFC('zf_tpl_suffix')}{$vo['ori']}</span>
                    <?php }else{ ?>
                      <span class="layui-badge layui-bg-green">{$vo['ori']}</span>
                    <?php }?>

                  </td>
                  <td>{$vo['filename']}</td>
                  <td>
                    {$vo['ctime']|date='Y-m-d H:i:s'}
                  </td>
                  <td>{$vo['size']}</td>
                  <td>
                    <button class="layui-btn btn_del layui-btn-danger layui-btn-xs  " rel="{$vo['filename']}" rel2="{$vo['ori']}" href="">删除</button>
                    <a class="layui-btn layui-btn-xs restore" ref="{:url('Mysql/restore',['name' => $vo['filename'],'t'=>'restore','ori' => $vo['ori']] )}" >还原</a>
                    <a class="layui-btn layui-btn-xs " href="{:url('Mysql/restore',['name' => $vo['filename'],'t'=>'get_sql','ori' => $vo['ori']] )}" >查看SQL</a>
                  </td>
                </tr>
              <?php } ?>     
            </tbody>
          </table>

      </div>
    </div>
  </div>
  {:widget_st('jq','js')}
  {:widget_st('layui','js')}
  {:widget_st('common','js')} 

  <script>
 layui.use(['element'], function(){
    var $ = layui.$
    ,form = layui.form
    ,element = layui.element;

    $('.restore').on('click',function() {
      var url = $(this).attr("ref");
      layer.confirm('确认还原？', {
        btn: ['还原', '取消'] //按钮
      }, function () {
        //执行还原操作
        var index = layer.load(1);
        $.get(url,function(res){
          layer.close(index);
          if(res.result==1){
            layer.msg("还原成功", {icon: 1});
            setTimeout(function() {
              location.reload(true);
            }, 1000);
          }else{
            layer.msg("还原失败", {icon: 1});
          }
        },"json");
      }, function () {
        //取消的操作
      });
    })
    // 删除
    $(".btn_del").on("click",function(){
      var name = $(this).attr("rel");
      var ori = $(this).attr("rel2");
      layer.confirm('确认删除？', {
        btn: ['删除','取消'] //按钮
      }, function(){
        //执行删除操作
        $.get("{:url('mysql/delete')}",{name:name,ori:ori},function(res){
          if(res.result==1){
            layer.msg("删除成功", {icon: 1});
            setTimeout(function() {
              location.reload(true);
            }, 1000);
          }else{
            layer.msg("删除失败", {icon: 1});
            
          }
        },"json");

      }, function(){
          //取消的操作
      });
    })

 
   
  });
  </script>
</body>
</html>
{:do_action('admin_js')}
